import logging
import unittest
import time
from selenium import webdriver
from Page import Page1
from ddt import ddt,data,file_data,unpack

from public import public

@ddt
class TestCase(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        public().log1()

    def tearDown(self):
        time.sleep(5)
        self.driver.quit()
    @file_data('login.yaml')
    def test_login1(self,username,password,exp,des):
        print(f'{username}======{password}=={exp}=={des}')
        logging.info(f'user:{username},password:{password}')
        po = Page1(self.driver)
        po.get_uel('http://localhost:8082/')
        po.click_mnyk()
        time.sleep(1)
        po.click_loginz()
        time.sleep(1)
        po.sendK_username(username)
        time.sleep(1)
        po.sendK_pwd(password)
        time.sleep(1)
        po.click_logingo()
        time.sleep(3)
        self.driver.switch_to.alert.accept()
        time.sleep(1)
        if des == '登录成功':
            self.assertIn(exp, po.gettext(po.emptext))
        else:
            self.assertEqual(exp,po.gettext(po.userlogin))



if __name__ == '__main__':
    unittest.main()